<style lang="less" scoped>
.dotitle {
  height:0.8rem;
  line-height:0.8rem;
  border-bottom: 1px solid #ddd;
}
.detail-goods-list {
  padding-left:0;
  .dotitle,.list-goods-warp {
    padding-left:0.2rem;
    padding-right: 0.2rem;
  }
  .detail-num {
    border:none;
  }
}
.list-goods-warp {
  padding-bottom: 0;
  .goods {
    border-bottom: 1px solid #efefef;
    padding-bottom:0.2rem;
  }
  dl{
    padding:0.1rem 0 0.2rem;
  }
  dt,dd {
    color:#888;
    font-size: 12px;
    height:0.4rem;
    line-height:0.4rem;
  }
  dd {
    em {
      font-size:12px;
      margin-right:0.1rem;
    }
  }
}
</style>

<template>
  <div v-show="loaded">
    <div class="acpt-list-wrap mb30" >
      <div class="acpt-list-head cf">
        <span class="time f-l">结算单号：{{data.settlebillno}}</span>
      </div>
      <div class="acpt-list-body">
        <div class="txt">
            <p>结算金额：￥{{data.amount?data.amount.toFixed(2):'0.00'}}</p>
            <p>结算时间：{{data.settledate | time}}</p>
            <p>结算单位：{{data.medname}}</p>
            <p>结算周期：{{data.begindate | time}} - {{data.enddate | time}}</p>
        </div>
      </div>
    </div>

    <div class="detail-goods-list" v-for="idx in todolist">
      <div class="dotitle">业务单据：{{idx.dobillno}}</div>
      <div class="list-goods-warp" v-for="item in idx.goodList">
        <div class="displayflex goods">
          <div class="pic">
            <img :src="item.PictContent | filterImgUrl">
          </div>
          <div class="msg flex1">
            <p class="ft17">品名：{{item.goodsname}}</p>
            <p>规格：{{item.supplier_goodsspec}}</p>
            <p>批号：{{item.lot}}</p>
            <em class="def-color">共<span class="red">{{item.supplier_poqty}}</span>{{item.supplier_unit}}</em>
          </div>
        </div>
        <div class="invoice" v-if="item.invoiceinfor && item.invoiceinfor.length > 0">
          <dl>
            <dd v-for='(inv, i) in item.invoiceinfor'><em>第{{i + 1}}张</em> 发票号：{{inv.invoiceno}} ￥{{inv.invoiceamount | fmoney}}</dd>
          </dl>

        </div>
      </div>
      
      <div class="detail-num">
        总计<span class="red">￥{{data.amount | fmoney}}</span>，已结<span class="red">￥{{data.inovicedamount | fmoney}}</span>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  data(){
    return {
      data:{},
      todolist:[],
      loaded:false,
    }
  },
  created() {
    this.getData();
  },
  mounted() {

  },
  methods: {
    getData(){
      let query = {
        settlebillno: this.$route.query.billno,
      };
      this.Ajax.post('wxs/settle/getDetail', query).then((res) => {
        if (res.errorCode == 0) {
          this.data = res.data.settleinfo;
          this.todolist = res.data.goodlist;

          this.todolist.forEach(arg => {
            arg.TAmount = 0;
            arg.goodList.forEach(x => {
              arg.TAmount += x.amount || 0;
            })
          })

          this.loaded = true;
        } else {
          this.Toast({
            message: res.message || '操作异常，请稍后重试',
          });
          this.$router.go(-1);
        };
      });
    }
  },
}
</script>